package fantasyday.wowzolo.web.common;

import fantasyday.wowzolo.web.account.SignonPage;
import fantasyday.wowzolo.web.cart.CartPage;
import fantasyday.wowzolo.web.catalog.IndexPage;
import fantasyday.wowzolo.web.Character.SearchCharacter;
import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.apache.wicket.util.lang.PackageName;

public class WowzoloApplication extends WebApplication {

	public WowzoloApplication() {
	}

    @Override
	public void init() {
		super.init();
        configureSpringInjection();
		mount("catalog", PackageName.forClass(IndexPage.class));
		mount("cart", PackageName.forClass(CartPage.class));
		mount("account", PackageName.forClass(SignonPage.class));
        AuthorizationStrategy authorizationStrategy = new AuthorizationStrategy();
        getSecuritySettings().setAuthorizationStrategy(authorizationStrategy);
        getSecuritySettings().setUnauthorizedComponentInstantiationListener(authorizationStrategy);
    }

    protected void configureSpringInjection() {
        addComponentInstantiationListener(new SpringComponentInjector(this));
    }

    @Override
	public Class<? extends WebPage> getHomePage() {
	//	return IndexPage.class;
        return SearchCharacter.class;
	}
	
	@Override
    public Session newSession(Request request, Response response) {
        return new WowzoloSession(request);
    }
}
